package identifier;

import java.util.Comparator;
import java.util.TreeSet;

public class Demo001 {
    public static void main(String[] args) {
        TreeSet<Cat> treeSet = new TreeSet<>(new myAnimalComparator());
        treeSet.add(new Cat("A",25));
        treeSet.add(new Cat("C",28));
        treeSet.add(new Cat("D",30));
        treeSet.add(new Cat("B",24));
        System.out.println(treeSet);
    }

}
class  myMiniCatComparator implements Comparator<MiniCat>{


    @Override
    public int compare(MiniCat o1, MiniCat o2) {
        return o1.level-o2.level;
    }
}

class  myCatComparator implements Comparator<Cat>{


    @Override
    public int compare(Cat o1, Cat o2) {
        return o1.age-o2.age;
    }
}

class  myAnimalComparator implements Comparator<Animal>{

    @Override
    public int compare(Animal o1, Animal o2) {
        return o1.name.compareTo(o2.name);
    }
}